package com.xinghai.config;

import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author fullee
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "ma")
public class OskMaServiceConfiguration {

    private String appId;
    private String secret;
    private String aesKey;
    private String token;
    private String msgDataFormat;

    @Bean
    public WxMaServiceImpl mpService() {

        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        config.setAppid(appId);
        config.setSecret(secret);
//        config.setAesKey(aesKey);
        config.setToken(token);
        config.setMsgDataFormat(msgDataFormat);

        WxMaServiceImpl maService = new WxMaServiceImpl();
        maService.setWxMaConfig(config);

        return maService;
    }

}
